<?php

/**
 * languages actions.
 *
 * @package    sf_sandbox
 * @subpackage languages
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 8507 2008-04-17 17:32:20Z fabien $
 */
class languagesActions extends sfActions
{
  public function executeIndex()
  {
    $this->languagesList = LanguagesPeer::doSelect(new Criteria());
  }

  public function executeCreate()
  {
    $this->form = new LanguagesForm();

    $this->setTemplate('edit');
  }

  public function executeEdit($request)
  {
    $this->form = new LanguagesForm(LanguagesPeer::retrieveByPk($request->getParameter('languages_id')));
  }

  public function executeUpdate($request)
  {
    $this->forward404Unless($request->isMethod('post'));

    $this->form = new LanguagesForm(LanguagesPeer::retrieveByPk($request->getParameter('languages_id')));

    $this->form->bind($request->getParameter('languages'));
    if ($this->form->isValid())
    {
      $languages = $this->form->save();

      $this->redirect('languages/edit?languages_id='.$languages->getLanguagesId());
    }

    $this->setTemplate('edit');
  }

  public function executeDelete($request)
  {
    $this->forward404Unless($languages = LanguagesPeer::retrieveByPk($request->getParameter('languages_id')));

    $languages->delete();

    $this->redirect('languages/index');
  }
}
